package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Expose;
import com.ruoyi.system.service.IExposeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广告曝光Controller
 * 
 * @author ruoyi
 * @date 2024-04-14
 */
@RestController
@RequestMapping("/system/expose")
public class ExposeController extends BaseController
{
    @Autowired
    private IExposeService exposeService;

    /**
     * 查询广告曝光列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Expose expose)
    {
        startPage();
        List<Expose> list = exposeService.selectExposeList(expose);
        return getDataTable(list);
    }

    /**
     * 导出广告曝光列表
     */
    @Log(title = "广告曝光", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Expose expose)
    {
        List<Expose> list = exposeService.selectExposeList(expose);
        ExcelUtil<Expose> util = new ExcelUtil<Expose>(Expose.class);
        util.exportExcel(response, list, "广告曝光数据");
    }

    /**
     * 获取广告曝光详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(exposeService.selectExposeById(id));
    }

    /**
     * 新增广告曝光
     */
    @Log(title = "广告曝光", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Expose expose)
    {
        return toAjax(exposeService.insertExpose(expose));
    }

    /**
     * 修改广告曝光
     */
    @Log(title = "广告曝光", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Expose expose)
    {
        return toAjax(exposeService.updateExpose(expose));
    }

    /**
     * 删除广告曝光
     */
    @Log(title = "广告曝光", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(exposeService.deleteExposeByIds(ids));
    }
}
